home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectPlay / Maze / MazeCommon / DummyConnector.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-31  |  3.1 KB  |  134 lines

  1. //----------------------------------------------------------------------------
  2. // File: dummyconnector.h
  3. //
  4. // Desc: see main.cpp
  5. //
  6. // Copyright (c) 1999-2001 Microsoft Corp. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #ifndef _DUMMY_CONNECTOR_H
  9. #define _DUMMY_CONNECTOR_H
  10.  
  11.  
  12.  
  13.  
  14. //-----------------------------------------------------------------------------
  15. // Name: 
  16. // Desc: 
  17. //-----------------------------------------------------------------------------
  18. #include "NetAbstract.h"
  19. #include <tchar.h>
  20.  
  21.  
  22.  
  23.  
  24. //-----------------------------------------------------------------------------
  25. // Name: 
  26. // Desc: 
  27. //-----------------------------------------------------------------------------
  28. class CDummyConnectorServer : public IOutboundServer
  29. {
  30. public:
  31.     CDummyConnectorServer() : m_pTarget(NULL),m_dwID(0) {};
  32.  
  33.     void    SetTarget( INetClient* ptarget )
  34.     {
  35.         m_pTarget = ptarget;
  36.     };
  37.  
  38.     // From IOutboundServer
  39.     virtual HRESULT SendPacket( DWORD /*to*/ , void* data , DWORD size , BOOL /*guaranteed*/, DWORD /*dwTimeout*/ )
  40.     {
  41.         if ( m_pTarget )
  42.             return m_pTarget->OnPacket( m_dwID , data , size );
  43.         return S_OK;
  44.     };
  45.  
  46.     virtual HRESULT GetConnectionInfo( DWORD dwID, TCHAR* strConnectionInfo )
  47.     {
  48.         _tcscpy( strConnectionInfo, TEXT("") );
  49.         return S_OK;
  50.     }
  51.  
  52.     virtual HRESULT RejectClient( DWORD dwID, HRESULT hrReason )
  53.     {
  54.         return S_OK;
  55.     }
  56.  
  57. private:
  58.     INetClient* m_pTarget;
  59.     DWORD       m_dwID;
  60. };
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69. //-----------------------------------------------------------------------------
  70. // Name: 
  71. // Desc: 
  72. //-----------------------------------------------------------------------------
  73. class CDummyConnectorClient : public IOutboundClient
  74. {
  75. public:
  76.     CDummyConnectorClient() : m_pTarget(NULL),m_dwID(0) {};
  77.  
  78.     void    SetTarget( INetServer* ptarget )
  79.     {
  80.         m_pTarget = ptarget;
  81.     };
  82.  
  83.     // Connect (sends an "add connection" message to target)
  84.     void    Connect( DWORD id )
  85.     {
  86.         m_dwID = id;
  87.         if ( m_pTarget )
  88.             m_pTarget->OnAddConnection( id );
  89.     };
  90.  
  91.     // Disconnect (sends a "remove connection" message to target
  92.     void    Disconnect( DWORD id )
  93.     {
  94.         if ( m_pTarget )
  95.             m_pTarget->OnRemoveConnection( m_dwID );
  96.     }
  97.  
  98.     // From IOutboundClient
  99.     virtual HRESULT SendPacket( void* data , DWORD size , BOOL /*guaranteed*/, DWORD /*dwTimeout*/ )
  100.     {
  101.         if ( m_pTarget )
  102.             return m_pTarget->OnPacket( m_dwID , data , size );
  103.         return S_OK;
  104.     };
  105.  
  106.     virtual DWORD GetThroughputBPS()
  107.     {
  108.         return 0;
  109.     }
  110.  
  111.     virtual DWORD GetRoundTripLatencyMS()
  112.     {
  113.         return 0;
  114.     }
  115.  
  116.     virtual BOOL    IsSessionLost() { return FALSE; };
  117.     virtual DWORD   GetSessionLostReason() { return 0; };
  118.  
  119.     virtual HRESULT GetConnectionInfo( TCHAR* strConnectionInfo )
  120.     {
  121.         _tcscpy( strConnectionInfo, TEXT("") );
  122.         return S_OK;
  123.     }
  124.  
  125. private:
  126.     INetServer* m_pTarget;
  127.     DWORD       m_dwID;
  128. };
  129.  
  130.  
  131.  
  132.  
  133. #endif
  134.